import 'package:flutter/cupertino.dart';
import 'package:old_shop/login&regist/login.dart';
import 'package:old_shop/main.dart';
import 'package:old_shop/page/friend/page/video_page.dart';

import 'login&regist/forget_pwd.dart';
import 'login&regist/pwd_login.dart';
import 'login&regist/pwd_setting.dart';
import 'login&regist/regist_page.dart';
import 'login&regist/reset_pwd.dart';
import 'login&regist/sms_code.dart';
import 'root/root.dart';

final routes = {
  // tabbar
  '/root': (context) => RootPage(),
  '/smscode': (context, {arguments}) => SmsCodePage(
        params: arguments,
      ), // 验证码登录
  '/pwdlogin': (context, {arguments}) => PwdLoginPage(
        params: arguments,
      ), // 密码登录
  '/pwdsetting': (context, {arguments}) => PwdSettingPage(
        params: arguments,
      ), // 第一次登录密码设置
  '/forgetpwd': (context) => ForgetPwdPage(), // 忘记密码
  '/resetpwd': (context, {arguments}) => ResetPwdPage(
        params: arguments,
      ), // 重新设置密码
  '/regist': (context, {arguments}) => RegistPage(), // 验证码登录
  '/login': (context, {arguments}) => LoginPage(
        params: arguments,
      ), // 验证码登录
  '/video': (context, {arguments}) => VideoPage(
        params: arguments,
      ), // 验
};

final onGenerateRoute = (RouteSettings settings) {
  // 统一处理
  final String name = settings.name!;
  final Function? pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route<dynamic> route =
          CupertinoPageRoute(builder: (context) => pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route<dynamic> route = CupertinoPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
  return null;
};
